<template>
  <el-input v-model="value" @input="handleChange" :disabled="disabled"></el-input>
</template>
<script>
export default {
  data() {
    return {};
  },
  model: {
    prop: "value",
    event: "innerInput",
  },
  methods: {
    handleChange(value) {
      if (isNaN(value)) {
        this.value = null;
      }

      value = Number(value);

      let precisionValue = value.toFixed(this.precision);

      value = Number(precisionValue);

      this.$emit("innerInput", this.value);
      this.$emit("input", this.value);
    },
  },
  props: {
    value: {
      type: Number,
      default: null,
    },
    precision: {
      type: Number,
      default: 2,
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
};
</script>
<style scoped></style>
